{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[0.3801151 , 0.13544728],\n",
       "       [0.0401349 , 0.92295763],\n",
       "       [0.39534362, 0.07349419],\n",
       "       [0.64503705, 0.03793501]])"
      ]
     },
     "execution_count": 19,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import numpy as np\n",
    "import pandas as pd\n",
    "data=np.array(np.random.random(size=(4,2)))\n",
    "data"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0.13372731464230478 0.36568745486043785\n"
     ]
    }
   ],
   "source": [
    "data = data[:,1]\n",
    "a = np.var(data)\n",
    "b = np.std(data)\n",
    "print(a,b)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([0.11018055, 1.        , 0.04017884, 0.        ])"
      ]
     },
     "execution_count": 21,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "def ping(x):\n",
    "    y = [(i-min(x))/(max(x)-min(x)) for i in x]\n",
    "    return y\n",
    "np.apply_along_axis(ping,0,data)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([0.11018055, 1.        , 0.04017884, 0.        ])"
      ]
     },
     "execution_count": 22,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "from my_sklearn.my_knn import My_knn\n",
    "my=My_knn()\n",
    "np.apply_along_axis(my.mymax,0,data)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[0.13544728 0.92295763 0.07349419 0.03793501]\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "array([-1.17411501,  4.71481169, -1.63739425, -1.90330243])"
      ]
     },
     "execution_count": 23,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "def ping(x):\n",
    "    return [(i-np.mean(x))/np.var(x) for i in x]\n",
    "print(data)\n",
    "np.apply_along_axis(ping,0,data)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "metadata": {},
   "outputs": [
    {
     "ename": "AttributeError",
     "evalue": "type object 'My_knn' has no attribute 'mean_var1'",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mAttributeError\u001b[0m                            Traceback (most recent call last)",
      "\u001b[1;32m<ipython-input-24-bf4d6a2758e5>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m()\u001b[0m\n\u001b[0;32m      2\u001b[0m \u001b[1;32mfrom\u001b[0m \u001b[0mmy_sklearn\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mmy_knn\u001b[0m \u001b[1;32mimport\u001b[0m \u001b[0mMy_knn\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m      3\u001b[0m \u001b[0ma\u001b[0m\u001b[1;33m=\u001b[0m\u001b[0mnp\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mapply_along_axis\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mMy_knn\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mmean_var\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;36m0\u001b[0m\u001b[1;33m,\u001b[0m\u001b[0mdata\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m----> 4\u001b[1;33m \u001b[0mb\u001b[0m\u001b[1;33m=\u001b[0m\u001b[0mnp\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mapply_along_axis\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mMy_knn\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mmean_var1\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;36m0\u001b[0m\u001b[1;33m,\u001b[0m\u001b[0mdata\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m",
      "\u001b[1;31mAttributeError\u001b[0m: type object 'My_knn' has no attribute 'mean_var1'"
     ]
    }
   ],
   "source": [
    "import numpy as np\n",
    "from my_sklearn.my_knn import My_knn\n",
    "a=np.apply_along_axis(My_knn.mean_var,0,data)\n",
    "b=np.apply_along_axis(My_knn.mean_var1,0,data)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.5"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
